<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>查看院校管理信息</title>
    <link rel="stylesheet" href="css/reset.css">
    <link rel="stylesheet" href="css/BX_heard.css">
    <link rel="stylesheet" href="css/BX_schoolInfo.css">
    <link rel="stylesheet" href="http://at.alicdn.com/t/font_1437774_idtdmqh48e.css">
    <link rel="stylesheet" href="css/layui/css/layui.css " media="all">
    <link rel="stylesheet" href="./font-awesome-4.7.0/css/font-awesome.css">
</head>
<body>
    <div class="heardFont"> 
        <span>院校管理</span>
        <strong class="heardDiff">/ 院校信息</strong>
        <em class="icon iconfont icon-xiugai"> 修改信息</em>
    </div>
    <div id="content">
        <div id="contLeft">
            <div class="contheard">
                基本信息
                
            </div>
            <div class="contFirst">
                <label >院系名称</label>
                <input type="text" name="" id="schoolName" placeholder="请输入院校名称">
            </div>
            <div class="contSecond">
                <label class="contSmll">院系</label>
                <input type="text" name="" id="department" placeholder="请输入院系">
                <label for="" style="margin-left: 40px;">学制</label>
                <input type="text" id="education" placeholder="学制">
            
            </div>
            <div class="contSecond">
                <label >所在地区</label>
                <select name="" id="province"></select>
                <select name="" id="city"></select>
                <!-- <input type="text" name="" id="" placeholder="所在地区"> -->
                <label for="" style="margin-left: 45px;">所属部门</label>
                <input type="text" id=" mage" placeholder="所属部门">
            </div>
            <div class="contFirst">
                <label >院系地址</label>
                <input type="text" name="" id="address" placeholder="请输入院校地址">
            </div>
            <div class="contFirst">
                <label >院系简介</label>
                <input type="text" name="" id="desc" placeholder="请输入院校简介">
            </div>
            <div class="contheard">
                院系联系人
            </div>
            <div class="contThree">
                <label >院系联系人姓名</label>
                <input type="text" name="" id="linkName" placeholder="院系联系人姓名">
            </div>
            <div class="contThree">
                <label >院系联系人电话</label>
                <input type="text" name="" id="linkTel" placeholder="院系联系人电话">
            </div>
        </div>
        <div id="contRight">
            <div class="contheard">
                学生数据信息
            </div>
            <div class="contTen">
                <label >目标学员数量</label>
                <input type="text" name="" id="target" placeholder="目标学员数量">
                <label >预计报名人数</label>
                <input type="text" name="" id="" placeholder="预计报名人数" >
            </div>
            <div class="contTen">
                <label >实际招生人数</label>
                <input type="text" name="" id="planNum" placeholder="实际招生人数">
                <label >学生离校时间</label>
                <input type="text" name="" id="leaveTime" placeholder="离校时间">
                <span id="leave" class="icon iconfont icon-riliriqi"></span>
            </div>
            <div class="contTen">
                <label class="labeCss">预计活动方式</label>
                <input type="text" name="" id="activePlay" placeholder="预计活动方式">
                <span class="over"></span>
                <label class="planTime1">计划活动时间</label>
                <input type="text" name="" id="timePlan" placeholder="计划活动时间">
                <span id="plan" class="icon iconfont icon-riliriqi"></span>
            </div>
            <div class="contheard">
                    考研/专升本比例
            </div>
            <div class="contFive">
                <label >考研比例</label>
                <input type="text" name="" id="postgraduate" placeholder="预计活动方式">
                <label >专升本比例</label>
                <input type="text" name="" id="topUp" placeholder="计划活动时间">
            </div>
            <div class="contheard">
                本公司以往招生信息
            </div>
            <div class="contTen">
                <label >以往活动方式</label>
                <input type="text" name="" id="setActive"  placeholder="活动方式">
                <label >以往培训总数</label>
                <input type="text" name="" id="StudySum" placeholder="培训总数">
            </div>
            <div class="contSix">
                <label >以往招生总数</label>
                <input type="text" name="" id="RecruitNum" placeholder="以往招生总数">
            </div>
        </div>
        <div id="footer">
            <div class="contheard">
                竞争对手
                <span class="icon iconfont icon-tianjia">添加</span>
            </div>
            <div id="footerInfo">
                <div class="footOne">
                    <label>公司名称</label>
                    <input type="text" name="" id="" class = "firmName" placeholder="公司名称">
                </div>
                <div class="footTwo">
                    <label>竞争学科</label>
                    <input type="text" name="" id="" class = "frimSubject" placeholder="竞争学科">
                    <label for="">学费金额</label>
                    <input type="text" name="" id="" class = "tuition"  placeholder="学费金额">
                </div>
                <div class="footTwo">
                        <label>招生方式</label>
                        <input type="text" name="" id="" class = "recruitWay"placeholder="招生方式">
                        <label for="">招生人数</label>
                        <input type="text" name="" id="" class = "recruitNum"placeholder="招生人数">
                    </div>
            </div>
        </div>
        <div id="last">
            <div class="contheard">
                记录信息
            </div>
            <div id="writeInfo"> 
                <!-- <div class="lastOne">
                    <label for="">记录类型</label>
                    <input type="text" name="" id="" placeholder="记录类型">
                </div> -->
                <div class="lastTwo">
                    <label for="">记录类型</label>
                    <textarea autocomplete="off" placeholder="请录入记录详情" class="textWrite" id="textWrite" style="min-height: 33px; margin-top: 0px; margin-bottom: 0px; height: 33px;"></textarea>
                </div>
            </div>
            
        </div>
        <div id="addWriteInfo">
                添加记录
        </div>
        <div id="butnBA">
                <span class="icon iconfont icon-tijiao">  提交</span>
        </div>
    </div>
    
</body>
</html>
<script src="js/jquery-3.4.1.js"></script>
<script src="css/layui/layui.js"></script>
<script src="js/drop-down option.js"></script>
<script src="js/BX_school.js"></script>
<script src="./js/url.js"></script>
<script>
   
    // 自定义的下拉选框
    
     
    lxcselector("#activePlay",3,["实训","讲座","宣讲"],20,40,145)
    lxcselector("#setActive",5,["口碑","网资","地推","社招","合作企业"],20,40,-20)
    
    // 设置ipunt 的手势和禁止
    $("input").css({
        cursor: "not-allowed",
        background:"#fff"
    }).attr("readonly","readonly")
    $("select").css({
        cursor: "not-allowed",
        background:"#fff"
    }).attr("disabled","disabled")
   
   
    $("#footer span").css("display","none");
    $("#addWriteInfo").css("display","none");
    $("#butnBA").css("display","none");

    // 点击修改信息
    $(".heardFont em").on("click",function(){
        $("#footerInfo").css("display","block");
        $("#writeInfo").css("display","block");
        $("input").css({
        cursor: "auto",
        background:"#fff"
        }).removeAttr("readonly")
        $("select").css({
            cursor: "auto",
            background:"#fff"
        }).removeAttr("disabled")
        $(".planTime").removeClass()
        $("#planTime").addClass("planTime1")

        $(".setActive").prop("id","setActive")

        layui.use('laydate', function () {
            var laydate = layui.laydate;
            laydate.render({
                elem: '#leaveTime',
                
            });
        });
        layui.use('laydate', function () {
            var laydate = layui.laydate;
            laydate.render({
                elem: "#timePlan",
                
            });
        });
        // 修改信息提交

        // $("#butnBA span").on("click",function(){
        //     console.log("1");
        //     var departperson = {
        //         "name":$("#linkName").val(),
        //         "tel":$("#linkTel").val()
        //     };
        //     var depart = String(departperson);
        //     var compet = {
        //         firmName :$(".firmName").val(),
        //         frimSubject :$(".frimSubject").val(),
        //         tuition:$(".tuition").val(),
        //         recruitWay:$(".recruitWay").val(),
        //         recruitNum:$(".recruitNum").val()
        //     }
        //     $.ajax({
        //         url:SetUrl.schoolUrl,
        //         type:"get",
        //         data:{
        //             "method":"addschool",
        //             "schoolName":$("#schoolName").val(),
        //             // schoolCode:$("#schoolName").val(),
        //             "competentDept":$("#mage").val(),
        //             "address":$("#address").val(),
        //             "education":$("#education").val(),
        //             'desc':$("#desc").val(),
        //             // "inputId":$("#inputId").val(),
        //             // "inputTime" :$("#schoolName").val(),
        //             // "modifyId":$("#schoolName").val(),
        //             // "modifyTime":$("#schoolName").val(),
        //             // "acquireId":$("#schoolName").val(),
        //             // "acquireTime":$("#schoolName").val(),
        //             "department":$("#department").val(),
        //             "departConnection":"depart",
        //             // "empId":$("#schoolName").val(),
        //             "targetStudentSum":$("#target").val(),
        //             "beforeStudySum":$("#StudySum").val(),
        //             "postgraduateExam":$("#postgraduate").val(),
        //             "topUpExam":$("#topUp").val(),
        //             "competition":"compet",
        //             "beforeRecruitNum":$("#RecruitNum").val(),
        //             "beforeActivity":$("#setActive").val(),
        //             "planActivity":$("#activePlay").val(),
        //             "planRecruitNum":$("#planNum").val(),
        //             "activityTime":$("#timePlan").val(),
        //             "leaveTime":$("#leaveTime").val(),
        //             "realityNum":$("#planNum").val(),
        //             "regionId":$("#city").find("option:selected").val(),
        //             "recordContent":$("#textWrite").val()

        //         },
        //         dataType:"json",
        //         success:function(data){
                    
        //             window.location.href="BX_schoolManage.html"
        //         },
        //         error:function(xhr,err){
        //             console.log(err)
        //         }
        //     })
        // })



        $("#footer span").css("display","block");
        $("#addWriteInfo").css("display","block");
        $("#butnBA").css("display","block");


        $("input").removeAttr("readonly");

        $("input").css({
        cursor: "auto",
        })
        $(".heardFont em").off("click")
    })

   
    $("#footer span").on("click",function(){
        $("#footerInfo").css("display","block");
    })
    $("#addWriteInfo").on("click",function(){
        $("#writeInfo").css("display","block");
    })

    $("#butnBA span").on('click',function(){
        console.log(localStorage.getItem("empId"))
        var cDapart = '{"name"' + ':' + '"' + $("#linkName").val() + '"' + ',' + '"tel"' + ':' + '"' + $("#linkTel").val()+ '"}';
        var compet = '{"name"' + ':' + '"' + $(".firmName").val() + '"' + ',' + '"tive"' + ':' + '"' + $(".frimSubject").val() + '"' + ',' + '"money"' + ':' + '"' + $(".tuition").val() + '"' + ',' + '"recruitstu"' + ':' + '"' + $(".recruitWay").val()+ '"' + ',' + '"recruitcou"' + ':' + '"' +$(".recruitNum").val() + '"}';

        // var departperson = {
        //     "name":$("#linkName").val(),
        //     "tel":$("#linkTel").val()
        // };
        // var depart =  JSON.stringify(departperson);
        // var compet = {
        //     firmName :$(".firmName").val(),
        //     frimSubject :$(".frimSubject").val(),
        //     tuition:$(".tuition").val(),
        //     recruitWay:$(".recruitWay").val(),
        //     recruitNum:$(".recruitNum").val()
        // }
        // var competString = JSON.stringify(compet);
        var id =localStorage.schoolId;
        var newRecordId = localStorage.recordId
        // console.log("id"+id);
        $.ajax({
            url:SetUrl.schoolUrl,
            type:"get",
            data:{
                "method":"updateschool",
                "id" : id,
                "schoolName":$("#schoolName").val(),
                // schoolCode:$("#schoolName").val(),
                "competentDept":$("#mage").val(),
                "address":$("#address").val(),
                "education":$("#education").val(),
                'desc':$("#desc").val(),
                // "inputId":$("#inputId").val(),
                // "inputTime" :$("#schoolName").val(),
                // "modifyId":$("#schoolName").val(),
                // "modifyTime":$("#schoolName").val(),
                // "acquireId":$("#schoolName").val(),
                // "acquireTime":$("#schoolName").val(),
                "department":$("#department").val(),
                "departConnection":cDapart,
                "modifyId":localStorage.getItem("empId"), //当前登陆员工id
                "targetStudentSum":$("#target").val(),
                "beforeStudySum":$("#StudySum").val(),
                "postgraduateExam":$("#postgraduate").val(),
                "topUpExam":$("#topUp").val(),
                "competition":compet,
                "beforeRecruitNum":$("#RecruitNum").val(),
                "beforeActivity":$("#setActive").val(),
                "planActivity":$("#activePlay").val(),
                "planRecruitNum":$("#planNum").val(),
                "activityTime":$("#timePlan").val(),
                "leaveTime":$("#leaveTime").val(),
                "realityNum":$("#planNum").val(),
                "regionId":newRecordId,
                // "recordContent":$("#textWrite").val()

            },
            dataType:"json",
            success:function(data){
                console.log(data.code)
                if(data.code == 100){
                    // window.location.href="BX_schoolManage.html"
                }
                
            },
            error:function(xhr,err){
                console.log(err)
            }
        })

    })
    
    $(function(){
        var setId = localStorage.schoolId;
        $.ajax({
            type: "get",
            url: SetUrl.schoolUrl,
            dataType: "json",
            data: {
                "method": "oneschool",
                "id":setId
            },
            success: function (data) {
                console.log(data)
                var list = data.result;
                var time = parseInt( list.leaveTime);
                var newTime = new Date(time);
                var iY = newTime.getFullYear() ||0;
                var iMonth = newTime.getMonth() + 1 ||0;
                var iDay = newTime.getDate()||0;
                var cityAddr = $("#city").val()||"";
                var newName = JSON.parse(list.departConnection);
                // 学校名称
                $("#schoolName").val(list.schoolName);
                // 省份
                $("#province select").val(list.address);
                // 学校地址
                $("#address").val(list.address +" "+cityAddr);
                // 实际招生数量
                $("#realityNum").val(list.realityNum)
                // 目标学员数量
                $("#targetStudentSum").val(list.targetStudentSum)
                // 预计报名人数
                $("#planRecruitNum").val(list.planRecruitNum)

                // 以往培训总数
                $("#beforeStudySum").val(list.beforeStudySum)
                // 以往招生总数
                $("#beforeRecruitNum").val(list.beforeRecruitNum)
                // 院系联系人姓名
                $("#departName").val(newName.name)
                // 院系联系人电话
                $("#departPho").val(newName.tel)
                // 学生离校时间
                $("#leaveTime").val(iY+ ' - '+ iMonth+' - '+ iDay);
                // 
                $("#timePlan").val(list.activityTime);
                
            }

        })
    })

   
    
    
</script>
